<script>

    function doChangeStatus(id, status) {
        ajaxGet("#(CPATH)/admin/article/doChangeStatus?id=" + id + "&status=" + status)
    }

    function doDelComment(id) {
        if (confirm("确定要删除这条评论吗？删除后不可恢复")) {
            ajaxGet("#(CPATH)/admin/article/comment/doDel?id=" + id);
        }
    }

</script>
<style>
    .comment-content {
        padding-bottom: 20px;
    }

    .comment-content p {
        display: inline;
    }

    table td a{
        color:#007bff;
    }

</style>

<div class="col-md-6 col-sm-6 col-12">
    <div class="card card-outline card-dashboard">
        <div class="card-header with-border">
            <h3 class="card-title">最新文章</h3>
        </div>
        <!-- /.card-header -->
        <div class="card-body p-0">
            <table class="table table-striped">
                <tbody>
                #for(article : articles)
                <tr>
                    <td style="width: 150px">#date(article.created ??)</td>
                    <td><a href="#(article.url ??)" target="_blank">#(article.title ??)</a></td>
                </tr>
                #end
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="col-md-6 col-sm-6 col-12">
    <div class="card card-outline card-dashboard">
        <div class="card-header with-border">
            <h3 class="card-title">最新评论</h3>
        </div>
        <div class="card-body p-0">
            <table class="table table-striped">
                <tbody>
                #for(comment : articleComments)
                <tr>
                    <td>
                        <div class="post">
                            <div class="user-block">
                                <img class="img-circle img-bordered-sm" src="#(comment.user.avatar ??)">
                                <span class="username"><a href="#(CPATH)/admin/user/detail/#(comment.user.id ??)">#(comment.author ??)</a></span>
                                <span class="description">#date(comment.created) -  来至对文章
                                    <a href="#(comment.article.url ??)" target="_blank">《#(comment.article.title ??)》</a> 的评论
                                </span>
                            </div>
                            <div class="comment-content" style="color:#333;">
                                #(comment.content ??)
                                #if(!comment.isNormal()) <strong style="color: #000">（#(comment.statusString)）</strong>
                                #end
                            </div>
                            <ul class="list-inline">
                                <li>
                                    <a href="#(CPATH)/admin/article/comment/reply/#(comment.id)" style="color: #006505">回复</a> |
                                    #if(comment.isNormal())
                                    <a href="javascript:;" onclick="doChangeStatus('#(comment.id)','unaudited')"
                                       style="color: #006505">待审核</a> |
                                    #else
                                    <a href="javascript:;" onclick="doChangeStatus('#(comment.id)','normal')"
                                       style="color: #006505">审核</a> |
                                    #end
                                    <a href="javascript:;" onclick="doChangeStatus('#(comment.id)','trash')"
                                       style="color: #a00">垃圾箱</a> |
                                    <a href="javascript:;" onclick="doDelComment('#(comment.id)')" style="color: #a00">永久删除</a>
                                </li>
                            </ul>
                        </div>
                    </td>
                </tr>
                #end
                </tbody>
            </table>
        </div>

    </div>
</div>